import Vue from 'vue'

Vue.filter('encodeHtml', function (str) {
	if(!str) return '';
    var arrEntities = {'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
    return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, (all,t) => arrEntities[t]); //function(all,t){return arrEntities[t];}
})

Vue.filter('imgSize', (input, size)=>{
	console.log('size',size);
	if( !input ) return '/images/placeholder.png';
    let imgSize = '?imageView2/2/w/';
    switch(size){
    	case 'lg': imgSize += '700';break;
    	case 'md': imgSize += '400'; break;
    	case 'sm': imgSize += '200'; break;
    	default: imgSize += '200';break;
    }
	return input+imgSize
})